<template>
  <div>
    <!-- 上方搜索栏 -->
    <div class="ty_search">
      <el-form :inline="true" :model="formInline" label-width="90px">
        <el-form-item label="标题" size="mini">
          <el-input
            v-model="formInline.user"
            placeholder="请输入标题"
          ></el-input>
        </el-form-item>

        <el-form-item label="类型" size="mini">
          <el-cascader
            :options="options"
            :props="{ multiple: true, checkStrictly: true }"
            clearable
            collapse-tags
          ></el-cascader>
        </el-form-item>
        <el-form-item label="是否轮播" size="mini">
          <el-select v-model="formInline.TYPE2" placeholder="请选择是否轮播">
            <el-option label="是" value="7"></el-option>
            <el-option label="否" value="8"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状态" size="mini">
          <el-select v-model="formInline.TYPE2" placeholder="请选择状态">
            <el-option label="已发布" value="7"></el-option>
            <el-option label="未发布" value="8"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item size="mini">
          <el-button
            type="primary"
            @click="onSubmit(formInline)"
            icon="el-icon-search"
            >查询</el-button
          >
          <el-button @click="cancel" icon="el-icon-refresh-right"
            >清空</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <el-card>
      <!-- 表格上方按钮 -->
      <div style="margin-bottom: 10px">
        <el-button type="primary" size="mini" @click="add" icon="el-icon-plus"
          >新 增</el-button
        >
        <el-button size="mini" type="danger" icon="el-icon-delete"
        @click="batchDelete"
          >批量删除</el-button
        >
        <el-button size="mini" type="success" icon="el-icon-check"
          >批量发布</el-button
        >
        <el-button size="mini" type="success" icon="el-icon-check"
          >撤销批量发布</el-button
        >
      </div>
      <el-table
        border
        ref="multipleTable"
        :data="tableData"
        style="width: 100%"
        height="40vh"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column type="index" width="50" label="序号">
        </el-table-column>
        <el-table-column prop="NAME" label="标题"></el-table-column>
        <el-table-column prop="NAME" label="最近一次编辑时间"></el-table-column>
        <el-table-column prop="NAME" label="类型"></el-table-column>
        <el-table-column prop="NAME" label="二级分类"></el-table-column>
        <el-table-column prop="NAME" label="是否置顶"></el-table-column>
        <el-table-column prop="NAME" label="是否轮播"></el-table-column>
        <el-table-column prop="NAME" label="状态"></el-table-column>
        <el-table-column fixed="right" label="操作" width="340">
          <template slot-scope="scope">
            <el-button type="text" size="small">查看</el-button>
            <el-button type="text" size="small" @click="edit">编辑</el-button>
            <el-button type="text" size="small">发布</el-button>
            <el-button type="text" size="small">撤销发布</el-button>
            <el-button type="text" size="small">删除</el-button>
            <el-button type="text" size="small">置顶</el-button>
            <el-button type="text" size="small">撤销置顶</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <MyPagination
        :pagination="pagination"
        @current-change="pageChange"
        @size-change="sizeChange"
      ></MyPagination>

      <Form ref="form" />
     
    </el-card>
  </div>
</template>
<script>
import MyPagination from "@/components/common/pagination.vue";
import Form from "./form.vue";

export default {
  components: {
    MyPagination,
    Form
   
  },
  data() {
    return {
      tableData: [
        {
          NAME: "测试数据",
        },
      ],
      pagination: {
        limit: 20,
        page: 1,
        total: 100,
      },
      formInline: {
        user: "",
        TYPE: "",
        TYPE2: "",
      },
      multipleSelection: [],
      options: [
        {
          value: "zhinan",
          label: "指南",
          children: [
            {
              value: "shejiyuanze",
              label: "设计原则",
            },
            {
              value: "yizhi",
              label: "一致",
            },
            {
              value: "fankui",
              label: "反馈",
            },
            {
              value: "xiaolv",
              label: "效率",
            },
            {
              value: "kekong",
              label: "可控",
            },
          ],
        },
      ],
    };
  },
  created() {
    // this.onSubmit(this.formInline);
  },
  methods: {
    add() {
      this.$refs.form.isShow();
    },
    edit(){
      this.$refs.form.isShow();
    },
    batchDelete(){
       this.$confirm('确定批量删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    onSubmit(formInline) {
      plstutatuscfApproveInfo({
        page: this.pagination.page,
        limit: this.pagination.limit,
        TYPE: this.formInline.TYPE,
        search: this.formInline.user,
      }).then((res) => {
        this.tableData = res.body;
      });
    },
    cancel() {
      // this.searchData.BUILDING_ID = "";
      // this.searchData.FLOOR_ID = "";
      // this.searchData.NAME = "";
      // this.get_list();
    },
    pageChange(val) {
      this.pagination.page = val;
      this.onSubmit(this.formInline);
    },
    sizeChange(val) {
      this.pagination.limit = val;
      this.onSubmit(this.formInline);
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-card__body {
  height: 100%;

  width: 100%;
}
</style>
